package com.baizhi.controller;

import com.baizhi.entity.News;
import com.baizhi.service.NewsService;
import com.baizhi.service.impl.NewsServiceImpl;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@RequestMapping("/news")
public class NewsController {
    private NewsService ns;
    @RequestMapping("selectAll")
    @ResponseBody
    public List<News> selectAll(){
        return ns.selectAll();
    }

    @RequestMapping("selectOne")
    @ResponseBody
    public News selectOne(int id){
        return ns.selectOne(id);
    }
    @RequestMapping("insert")
    @ResponseBody
    public void insert(News news){
        ns.insert(news);
    }
    @RequestMapping("delete")
    @ResponseBody
    public void delete(int id){
        ns.delete(id);
    }
    @RequestMapping("update")
    @ResponseBody
    public void update(News news){
        ns.update(news);
    }

    public NewsService getNs() {
        return ns;
    }

    public void setNs(NewsService ns) {
        this.ns = ns;
    }
}
